package com.fg.ihr.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fg.ihr.common.StringtoInteger;
import com.fg.ihr.domain.Department;
import com.fg.ihr.domain.Education;
import com.fg.ihr.domain.Ward;
import com.fg.ihr.repository.WardRepository;
import com.mysql.cj.xdevapi.JsonArray;
import com.mysql.cj.xdevapi.JsonString;
import org.json.JSONString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/ward")
public class WardController {
    private static final Logger logger = LoggerFactory.getLogger(WardController.class);

    @Autowired
    WardRepository wardRepository;

    @PostMapping("/list")
    @ResponseBody
    public String getWardList(@RequestParam(required = false) String array
    ) {

        List<Ward> result = wardRepository.findWardList(StringtoInteger.StoI(array));
        JSONArray list = JSONObject.parseArray(JSON.toJSONString(result));
        String wards = JSON.toJSONString(list);
        return wards;
             }
        }
